package com.ryskoo.catering.productspec.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.productspec.domain.ProductSpecPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class ProductSpecRedisImpl extends BasicRedisImpl<ProductSpecPO> implements IProductSpecRepository {

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IProductSpecRepository productSpecRepository;

    @PostConstruct
    public void init(){
        this.setRedisClient(redisClient);
        this.setDao(productSpecRepository);
    }

    public ProductSpecRedisImpl(){super(HCLCacheConstant.HCL_PRODUCTSPEC_KEY);}

    @Override
    public void deleteByMainUuid(String mainUuid) {
        productSpecRepository.deleteByMainUuid(mainUuid);
    }

    @Override
    public List<ProductSpecPO> getSpecsByMainUuid(String mainUuid) {
        return productSpecRepository.getSpecsByMainUuid(mainUuid);
    }

    @Override
    public void deleteByMainUuids(List<String> mainUuids) {
        productSpecRepository.deleteByMainUuids(mainUuids);
    }
}
